cannot use object of type stdclass as array

118

Cannot use object of type stdClass as array in isset -

function deliciousCount($domain_name) {
    $data = json_decode(
        file_get_contents(
            "http://feeds.delicious.com/v2/json/urlinfo/data?url=$domain_name"
        )
    );
    // You should double check everything because this delicious function is broken
    if (is_array($data) && isset($data[ 0 ]) &&
        $data[ 0 ] instanceof stdClass  && isset($data[ 0 ]->total_posts)) {
        return $data[ 0 ]->total_posts;
    } else {
        return 0;
    }
}

Comments

Submit
0 Comments